package group2assignone.ucm.customer;

import group2assignone.model.Customer;
import group2assignone.model.Flight;
import group2assignone.ucm.UCController;
import group2assignone.view.customer.AvailableFlightsView;
import group2assignone.view.customer.BookFlightView;

/**
 * use case to show the 'book flight' view
 * @author Flick
 */
public class UCUIBookFlight implements UCController {

    private AvailableFlightsView view;
    private Customer customer;
    private Flight flight;

    /**
     * The customer field is used for personalisation of view.
     * Default for customer that is not logged in is customer.
     * @param view
     * @param customer
     */
    public UCUIBookFlight(Customer customer, AvailableFlightsView view) {
        this.view = view;
        this.customer = customer;
    }

    /**
     * Use Case: Change UI to Book Flight
     * 1. system exits current view
     * 2. system updates gui to the book flight UI
     */
    public void run() {
        flight = new Flight();
        flight = view.getSelectedFlight();
        BookFlightView gui = new BookFlightView(customer, flight);
        gui.go();
        view.dispose();
    }
}
